package cn.lx.log.core.context;

import cn.lx.log.core.context.UserContext;
import cn.lx.log.core.context.UserContextImpl;
import cn.lx.log.core.entity.LogContext;
import sun.rmi.runtime.Log;

public class UserContextHolder {

    private static ThreadLocal<UserContext> contextHolder = new ThreadLocal<UserContext>();

    public UserContextHolder() {
    }

    public static void setContext(UserContext userContext) {
        contextHolder.set(userContext);
    }

    public static UserContext getContext() {
        UserContext userContext = contextHolder.get();
        if (userContext == null) {
            userContext = new UserContextImpl();
            setContext( userContext);
        }

        return userContext;
    }
}
